What is prosemirror-commands?
The prosemirror-commands package provides a set of predefined commands for manipulating the content of a ProseMirror editor. These commands cover a wide range of common editing actions, such as formatting text, inserting nodes, and manipulating the document structure.
What are prosemirror-commands's main functionalities?
Text Formatting
This feature allows you to toggle text formatting such as bold, italic, and underline. The code sample demonstrates how to create a command to toggle bold formatting using the ProseMirror schema.
const { toggleMark } = require('prosemirror-commands');
const { schema } = require('prosemirror-schema-basic');
// Example command to toggle bold formatting
const toggleBold = toggleMark(schema.marks.strong);
Node Insertion
This feature allows you to insert or change the type of nodes in the document. The code sample shows how to create a command to set a block type to a paragraph.
const { setBlockType } = require('prosemirror-commands');
const { schema } = require('prosemirror-schema-basic');
// Example command to set a paragraph block type
const setParagraph = setBlockType(schema.nodes.paragraph);
Document Manipulation
This feature provides commands for manipulating the document structure, such as joining blocks or splitting nodes. The code sample demonstrates how to create a command to join the current block with the one above it.
const { joinUp } = require('prosemirror-commands');
// Example command to join the current block with the one above it
const joinWithAbove = joinUp;
Other packages similar to prosemirror-commands
tiptap
Tiptap is a headless, framework-agnostic text editor built on top of ProseMirror. It provides a more modern and flexible API for creating rich text editors. Compared to prosemirror-commands, Tiptap offers a higher-level abstraction and additional features like collaborative editing and real-time collaboration.
slate
Slate is a completely customizable framework for building rich text editors. It provides a more flexible and extensible API compared to prosemirror-commands, allowing developers to define their own commands and behaviors. Slate is known for its ease of use and powerful plugin system.
draft-js
Draft.js is a rich text editor framework developed by Facebook. It provides a set of immutable models and helper functions for building rich text editors. While it offers similar functionalities to prosemirror-commands, Draft.js is more opinionated and tightly integrated with React.
prosemirror-commands
[ WEBSITE | ISSUES | FORUM | CHANGELOG ]
This is a core module of ProseMirror.
ProseMirror is a well-behaved rich semantic content editor based on
contentEditable, with support for collaborative editing and custom
document schemas.
This module implements a
number of editing commands, which are functions that abstract editing
actions which can be bound to keys.
The project page has more information, a
number of examples and the
documentation.
This code is released under an
MIT license.
There's a forum for general
discussion and support requests, and the
Github bug tracker
is the place to report issues.
We aim to be an inclusive, welcoming community. To make that explicit,
we have a code of
conduct that applies
to communication around the project.